package com.ruoyi.web.controller.kiku;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kiku.domain.KikuWeiBoConcern;
import com.ruoyi.kiku.service.IKikuWeiBoConcernService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 微博关注Controller
 *
 * @author TT
 * @date 2025-08-03
 */
@RestController
@RequestMapping("/kiku/concern")
public class KikuWeiBoConcernController extends BaseController
{
    @Autowired
    private IKikuWeiBoConcernService kikuWeiBoConcernService;

    /**
     * 查询微博关注列表
     */
    @PreAuthorize("@ss.hasPermi('kiku:concern:list')")
    @GetMapping("/list")
    public TableDataInfo list(KikuWeiBoConcern kikuWeiBoConcern)
    {
        startPage();
        List<KikuWeiBoConcern> list = kikuWeiBoConcernService.selectKikuWeiBoConcernList(kikuWeiBoConcern);
        return getDataTable(list);
    }

    /**
     * 导出微博关注列表
     */
    @PreAuthorize("@ss.hasPermi('kiku:concern:export')")
    @Log(title = "微博关注", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KikuWeiBoConcern kikuWeiBoConcern)
    {
        List<KikuWeiBoConcern> list = kikuWeiBoConcernService.selectKikuWeiBoConcernList(kikuWeiBoConcern);
        ExcelUtil<KikuWeiBoConcern> util = new ExcelUtil<KikuWeiBoConcern>(KikuWeiBoConcern.class);
        util.exportExcel(response, list, "微博关注数据");
    }

    /**
     * 获取微博关注详细信息
     */
    @PreAuthorize("@ss.hasPermi('kiku:concern:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(kikuWeiBoConcernService.selectKikuWeiBoConcernById(id));
    }

    /**
     * 新增微博关注
     */
    @PreAuthorize("@ss.hasPermi('kiku:concern:add')")
    @Log(title = "微博关注", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KikuWeiBoConcern kikuWeiBoConcern)
    {
        return toAjax(kikuWeiBoConcernService.insertKikuWeiBoConcern(kikuWeiBoConcern));
    }

    /**
     * 修改微博关注
     */
    @PreAuthorize("@ss.hasPermi('kiku:concern:edit')")
    @Log(title = "微博关注", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KikuWeiBoConcern kikuWeiBoConcern)
    {
        return toAjax(kikuWeiBoConcernService.updateKikuWeiBoConcern(kikuWeiBoConcern));
    }

    /**
     * 删除微博关注
     */
    @PreAuthorize("@ss.hasPermi('kiku:concern:remove')")
    @Log(title = "微博关注", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(kikuWeiBoConcernService.deleteKikuWeiBoConcernByIds(ids));
    }
}
